﻿using Leo.Common.MQTT;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Text.RegularExpressions;

namespace JwtAuth.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class MQTTController : ControllerBase
    {

        [HttpGet("test")]
        public async Task<string> GetTestMQTT()
        {
            //MQTTConfig config = new MQTTConfig();
            //var result = await config.CreateConnectionAsync();

            // 正则表达式模式：匹配[字母数字-任意字符]
            string pattern = @"\[(?:([A-Za-z0-9]+)-)?([^\]]+)\]";

            var strArr = new List<string>();

            // 获取所有匹配项
            MatchCollection matches = Regex.Matches("[-放入异物]", pattern);
            foreach (Match match in matches)
            {
                // 完整匹配+两个捕获组
                if (match.Groups.Count == 3)
                {
                    string code = match.Groups[1].Success ? match.Groups[1].Value : match.Groups[2].Value;
                    strArr.Add(code);
                }
            }


            return "OK";
        }

    }
}
